home *** CD-ROM | disk | FTP | other *** search
/ Varios Español / Varios Español.iso / DBASE5 / CUA_SAMP.ZIP / BLDDIRS.PRG < prev    next >
Text File  |  1994-10-12  |  2KB  |  83 lines

  1.  
  2. PROCEDURE BldDirs
  3. PARAMETERS poListBox
  4. *----------------------------------------------------------------------------
  5. * NAME
  6. *   BldDirs - Build a list of directories then set the DataSource.  This
  7. *             routine can be used whenever a listbox of directories from
  8. *             the current directory is needed.
  9. *
  10. * PARAMETERS
  11. *   poListBox  = Object ref to list box or combo box.
  12. *
  13. *----------------------------------------------------------------------------
  14.     PRIVATE cPath, n, i, nDirs, nMod, nOk, dB5___Dir, dB5___Ofls, nCurSel
  15.  
  16.     cPath = SET( "DIRECTORY" )
  17.     IF RIGHT( m->cPath, 1 ) <> "\"
  18.         cPath = m->cPath + "\"
  19.     ENDIF
  20.  
  21.     *--------------------------------
  22.     *-- Build the list of directories
  23.     *--------------------------------
  24.     poListBox.DataSource = "DIRECTORY " + m->cPath + "*.*"
  25.     lAddRoot = .T.
  26.     IF poListBox.Value == "."
  27.         poListBox.Value = "\"
  28.         lAddRoot = .F.
  29.     ELSE
  30.         IF ISBLANK( poListBox.Value )
  31.             lAddRoot = .F.
  32.         ENDIF
  33.     ENDIF
  34.  
  35.     *-------------------------------------------------------------------
  36.     *-- Not we have a list of directories, the next step is to pull them
  37.     *-- out of the listbox into an array to sort.
  38.     *-------------------------------------------------------------------
  39.     cItem = ""
  40.     nItems = 0
  41.     DECLARE dB5___Dir[255]
  42.     IF m->lAddRoot
  43.         dB5___Dir[1] = "\"
  44.         dB5___Dir[2] = ".."
  45.         nItems = 2
  46.     ENDIF
  47.  
  48.     nCurSel = 1
  49.     poListBox.CurSel = m->nCurSel
  50.  
  51.     DO WHILE m->cItem # poListBox.Value .AND. nItems < 255
  52.         cItem = poListBox.Value
  53.         nItems = m->nItems + 1
  54.         dB5___Dir[ m->nItems ] = poListBox.Value
  55.         nCurSel = m->nCurSel + 1
  56.         poListBox.CurSel =  m->nCurSel
  57.     ENDDO
  58.  
  59.     IF m->nItems = 0
  60.         dB5___Dir[1] = "\"
  61.         dB5___Dir[2] = ".."
  62.         nItems = 2
  63.     ENDIF
  64.  
  65.     nVoid = ARESIZE( dB5___Dir, m->nItems )
  66.  
  67.     IF m->nItems > 2 .AND. dB5___Dir[2] == ".."
  68.         nStart = 3
  69.     ELSE
  70.         nStart = 1
  71.     ENDIF
  72.  
  73.     IF m->nItems > 2
  74.         nVoid = ASORT( dB5___Dir, m->nStart )
  75.     ENDIF
  76.  
  77.     poListBox.DataSource = "ARRAY dB5___Dir"
  78.  
  79. RETURN
  80. *-- EOP: BldDirs
  81.  
  82.  
  83.